import unittest
from parameterized import parameterized
from common.read_json_data import build_data
from config import BASE_DIR
from api.login_api import LoginApi
import logging
from common.verify_result import common_assert


class TestLogin(unittest.TestCase):
    @parameterized.expand(build_data(BASE_DIR + "/data/login.json"))
    def test_login(self, case_name, body, expect_result):
        print(f"【{case_name}】接口测试")
        logging.info(f"【{case_name}】接口测试")
        print(f"body={body}")
        logging.info(f"body={body}")
        print(f"expect_result={expect_result}")
        logging.info(f"expect_result={expect_result}")

        loginapi = LoginApi()
        resp = loginapi.login(body)
        json_data = resp.json()
        print(f"json_data={json_data}")
        logging.info(f"json_data={json_data}")
        # self.assertEqual(expect_result["status_code"], resp.status_code)
        # self.assertEqual(expect_result["success"], json_data["success"])
        # self.assertEqual(expect_result["code"], json_data["code"])
        # self.assertIn(expect_result["message"], json_data["message"])
        common_assert(self,expect_result,resp)
